<template>
  <div class="bonus-config">
    <dt-grid ref="table" :columns="columns" :onFetch="onFetch" page />
    <check-modal ref="check" />
  </div>
</template>
<script>
  import columnOpt from './opt/column.js'
  import checkModal from './components/checkModal.vue'
  import extendMgr from '@/biz/bonus/bonusExtend.js'

  export default {
    data() {
      return {
        columns: []
      }
    },
    components: {
      checkModal
    },
    mounted() {
      this.$refs.table.init(this, new columnOpt(this))
      this.$refs.table.init(this)
      this.$refs.table.fetch()
    },

    methods: {
      onFetch(data) {
        data.housesId = this.$dt.buildInfo().housesId
        return extendMgr.getBoExtendList(data).then((res) => {
          return res
        })
      },
      onSuccsse() {
        this.$refs.table.fetch()
      },
      //查看
      checkFun(row) {
        row.title = '延期申请详情'
        row.type = 'check'
        this.$refs.check.show(row)
      },
      //撤回
      revocation(data) {
        this.$Modal.confirm({
          title: '提示',
          content: `请确认，是否撤回？`,
          okText: '确认',
          closable: true,
          onOk: () => {
            extendMgr
              .updateBoExtendStatus({
                extendId: data.extendId,
                operation: 'WITHDRAWN'
              })
              .then((res) => {
                this.$Message.success('撤回成功')
                this.onSuccsse()
              })
          }
        })
      },
      //删除
      delFun(data) {
        this.$Modal.confirm({
          title: '提示',
          content: `请确认，是否删除？`,
          okText: '确认',
          closable: true,
          onOk: () => {
            extendMgr.delBoExtend({ extendId: data.extendId }).then((res) => {
              this.$Message.success('删除成功')
              this.onSuccsse()
            })
          }
        })
      }
    }
  }
</script>

<style lang="scss" scoped>
  .bonus-config {
    padding: 20px;
  }
</style>
